package cn.ecnu.service.impl;

import cn.ecnu.entity.User;
import cn.ecnu.mapper.UserMapper;
import cn.ecnu.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RegisterServiceImpl implements RegisterService {


    private UserMapper mapper;

    @Autowired(required = false)
    public RegisterServiceImpl(UserMapper mapper) {
        this.mapper = mapper;
    }


    @Override
    public int countUserByPhone(String phone) {
        User user = mapper.getUserByPhone(phone);
        if (user != null) return 1;
        return 0;
    }

    @Override
    public int countUserByName(String username) {
        User user = mapper.getUserByName(username);
        if (user != null) return 1;
        return 0;
    }

    @Override
    public int insertUser(User user) {
        return mapper.insertUser(user);
    }
}
